package com.saturn.action.sldb.emergency;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.saturn.app.web.IAction;
import com.saturn.app.web.IView;
import com.saturn.app.web.view.JspErrorView;
import com.saturn.app.web.view.JspView;
import com.saturn.sldb.Emergency;

public class UploadFilesAction implements IAction{
	@Override
	public IView execute(HttpServletRequest request,
			HttpServletResponse response) {
		String id = request.getParameter("id");
		String files = request.getParameter("files");
		String type = request.getParameter("type");
		
		if("1".equals(type)){
			if(files!=null&&!"".equals(files)){
				if (Emergency.editFiles(id, files) == 1) {
					return new JspView("/app/sldb/emergency/approval/show.jsp");
				} else {
					return new JspErrorView("更新信息失败");
				}
			}
		} else if("2".equals(type)){
			if(files!=null&&!"".equals(files)){
				if (Emergency.editFiles(id, files) == 1) {
					return new JspView("/app/sldb/emergency/apply/show.jsp");
				} else {
					return new JspErrorView("更新信息失败");
				}
			}
		}else if("3".equals(type)){
			if(files!=null&&!"".equals(files)){
				if (Emergency.editFiles(id, files) == 1) {
					return new JspView("/app/sldb/approval/pending/show.jsp");
				} else {
					return new JspErrorView("更新信息失败");
				}
			}
		}else if("0".equals(type)){
			if(files!=null&&!"".equals(files)){
				if (Emergency.editFiles(id, files) == 1) {
					return new JspView("/app/sldb/emergency/apply/autoShow.jsp");
				} else {
					return new JspErrorView("更新信息失败");
				}
			}
		}else if("4".equals(type)){
			if(files!=null&&!"".equals(files)){
				if (Emergency.editFiles(id, files) == 1) {
					return new JspView("/app/sldb/emergency/ago/show.jsp");
				} else {
					return new JspErrorView("更新信息失败");
				}
			}
		}else if("5".equals(type)){
			if(files!=null&&!"".equals(files)){
				if (Emergency.editFiles(id, files) == 1) {
					return new JspView("/app/sldb/approval/ago/show.jsp");
				} else {
					return new JspErrorView("更新信息失败");
				}
			}
		}
		return new JspErrorView("无图片信息");
	}

	@Override
	public String requestMapping() {
		return "/app/sldb/emergency/uploadfiles.action";
	}
}
